package cn.com.inossem.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import cn.com.inossem.adapter.BankTypeAdapter;
import cn.com.inossem.base.RequestActivity;
import cn.com.inossem.requestmanager.WooRequestFactory;

/**
 * Created by Mickey.Li
 * Time 2017-10-9 下午 2:02
 */

public class SelectBankActivity extends RequestActivity {

	private RecyclerView rv_bank_type;
	private String[] bankType;
	private TextView common_title;

	@Override
	public int getContentViewId() {
		return R.layout.act_sel_bank;
	}

	@Override
	public void initAllMembers(Bundle savedInstanceState) {
		super.initAllMembers(savedInstanceState);
		bankType = getResources().getStringArray(R.array.bank_type);
		common_title = (TextView) findViewById(R.id.common_title);
		common_title.setText("银行类型");
		findViewById(R.id.common_back).setOnClickListener(this);
		findViewById(R.id.common_right_img).setVisibility(View.GONE);
		rv_bank_type = (RecyclerView) findViewById(R.id.rv_bank_type);
		rv_bank_type.setLayoutManager(new LinearLayoutManager(this));
		rv_bank_type.setAdapter(new BankTypeAdapter(this, this, bankType));
	}

	@Override
	public void onClick(View v) {
		super.onClick(v);
		switch (v.getId()) {
			case R.id.common_back:
				finish();
				break;
			case R.id.bank:
				launchRequest(WooRequestFactory.updatePersonal("bankType", bankType[(int) v.getTag()]));
				Intent intent = getIntent();
				int type = getIntent().getIntExtra("type", 0);
				intent.putExtra("name", bankType[(int) v.getTag()]);
				setResult(type, intent);
				finish();
		}
	}
}
